<template>
    <el-form-item label="开启多选">
        <el-switch v-model="optionModel.multiple" @change="handleChange"></el-switch>
    </el-form-item>
</template>

<script setup>
defineOptions({
    name:"multiple-editor"
})

const props = defineProps({
    optionModel:{
        type:Object,
        default:()=>({})
    },
    selectWidget:{
        type:Object,
        default:()=>({}) 
    },
    designer:{
        type:Object,
        default:()=>({}) 
    }
})

const handleSetFieldValue = (val)=>{
    const setFieldVal =props.designer.getCurFieldFunById(props.selectWidget.id)
    setFieldVal(val)
}

const handleChange = (v)=>{
    if(v){
        props.selectWidget.options.defaultValue = []
    }else {
        if(props.selectWidget.options.optionItems.length > 0){
            props.selectWidget.options.defaultValue = props.selectWidget.options.optionItems[0].value
        }else {
            props.selectWidget.options.defaultValue = ""
        }
    }
    handleSetFieldValue(props.selectWidget.options.defaultValue)
}
</script>

<style lang='scss' scoped></style>